package dfbz.课堂小练习1;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class demo01 {
    public static void main(String[] args) {
        String line = new Scanner(System.in).nextLine();
        //把用户输入的值转换为一个字符数组
        char[] chars = line.toCharArray();
        HashMap<Character,Integer> map = new HashMap<>();
        for (char aChar : chars) {
            if(!map.containsKey(aChar)){
                map.put(aChar,1);
            }else {
                Integer integer = map.get(aChar);
                map.put(aChar,++integer);
            }
        }
        System.out.println(map);
        Set<Map.Entry<Character, Integer>> entries = map.entrySet();
        for (Map.Entry<Character, Integer> entry : entries) {
            System.out.println("字母"+entry.getKey()+"出现的次数为:"+entry.getValue()+"次");
        }
    }
}
